package com.company.behavioral.chain_of_responsibility_pattern.concrete_handler;

import com.company.behavioral.chain_of_responsibility_pattern.PurchaseRequest;
import com.company.behavioral.chain_of_responsibility_pattern.handler.Approver;

/**
 * 主任
 * @ClassName Director
 * @Author tiezheng.han
 * @Date 2020/9/2 10:44
 **/
public class Director extends Approver {


    public Director(String name){
        super(name);
    }

    /**
     * 具体请求处理方法
     * @param request
     */
    @Override
    public void processRequest(PurchaseRequest request) {
        if (request.getAmount() < 50000){
            System.out.println("主任" + this.name + "审批采购单：" + request.getNumber() + "金额，" + request.getAmount()
                    + "元，采购目的：" + request.getPurpose() + "。");
        }else {
            // 转发请求
            this.successor.processRequest(request);
        }
    }
}
